﻿/// <reference path="../GeneratedArtifacts/viewModel.js" />
/// <reference path="../Scripts/jquery.signalR-1.0.1.js" />

myapp.Home.created = function (screen) {
    $.ajax({
        type: 'post',
        data: {},
        url: '../web/GetUserName.ashx',
        success: function success(result) {
            //screen.UserName = result; //cache user name for filtering
            screen.details.displayName = screen.details.displayName + " (" + result + ")";
        }
    });
    //defaultCountdown = $('#defaultCountdown');
    //if (defaultCountdown != null) {
    //    $(this).visible = true;
    //}
    //RefreshCountDown(null);

};

myapp.Home.MenuContent_render = function (element, contentItem) {
    var menuHtml = '<div id="divMenu" data-role="ui-content"><ul data-role="listview" data-inset="true" class="ui-listview ui-listview-inset ui-corner-all ui-shadow">'
        + '<li data-name="BrowseMovements" data-corners="false" data-shadow="false" data-iconshadow="true" data-wrapperels="div" data-icon="arrow-r" data-iconpos="right" data-theme="c" class="ui-btn ui-btn-icon-right ui-li-has-arrow ui-li ui-corner-top ui-btn-up-c"><img src="Content/Images/movement.gif"/><div class="ui-li-desc">Movements</div></li>'
        + '<li data-name="BrowseCars" data-corners="false" data-shadow="false" data-iconshadow="true" data-wrapperels="div" data-icon="arrow-r" data-iconpos="right" data-theme="c" class="ui-btn ui-btn-icon-right ui-li-has-arrow ui-li ui-corner-top ui-btn-up-c"><img src="Content/Images/car.gif"/><div class="ui-li-desc">Cars</div></li>'
        + '<li data-name="BrowseFavorites" data-corners="false" data-shadow="false" data-iconshadow="true" data-wrapperels="div" data-icon="arrow-r" data-iconpos="right" data-theme="c" class="ui-btn ui-btn-icon-right ui-li-has-arrow ui-li ui-corner-top ui-btn-up-c"><img src="Content/Images/favorite.png"/><div class="ui-li-desc">Favorites</div></li>'
        + '<li data-name="BrowsePlaces" data-corners="false" data-shadow="false" data-iconshadow="true" data-wrapperels="div" data-icon="arrow-r" data-iconpos="right" data-theme="c" class="ui-btn ui-btn-icon-right ui-li-has-arrow ui-li ui-corner-top ui-btn-up-c"><img src="Content/Images/place.gif"/><div class="ui-li-desc">Places</div></li>'
        + '<li data-name="BrowseRestrictions" data-corners="false" data-shadow="false" data-iconshadow="true" data-wrapperels="div" data-icon="arrow-r" data-iconpos="right" data-theme="c" class="ui-btn ui-btn-icon-right ui-li-has-arrow ui-li ui-corner-top ui-btn-up-c"><img src="Content/Images/restriction.gif"/><div class="ui-li-desc">Restrictions</div></li>'
     + '</ul></div>​';

    $selectElement = $(menuHtml).appendTo($(element));
    $('#divMenu ul').children('li').bind('touchstart mousedown', function (e) {
        myapp.showScreen($(this).attr('data-name'));
    });

    //var $firstTextBox = $("input[type=text]", $(element)); //get the input tag
    /*setTimeout(function () {
        $firstTextBox.focus(); //set the focus
    }, 2);*/
};